package com.zhima.constant;

import java.util.concurrent.TimeUnit;

public class RedisConstant {
    /**
     * 保存登录用户
     */
    public static final String LOGIN_USER_PREFIX = "login";
    /**
     * 保存手机发送的验证码
     */
    public static final String PHONE_CHECK_CODE_PREFIX = "checkcode:phone";
    /**
     * 保存邮箱发送的验证码
     */
    public static final String EMAIL_CHECK_CODE_PREFIX = "checkcode:email";

    /**
     * 验证码过期时间单位
     */
    public static final TimeUnit CHECK_CODE_EXPIRE_TIME_UNIT = TimeUnit.SECONDS;
    /**
     * 验证码过期时间
     */
    public static final Integer CHECK_CODE_EXPIRE_TIME = 60 * 5;

    public static String loginUserKey(Long userId) {
        return String.format("%s:%s", LOGIN_USER_PREFIX, userId.toString());
    }

    public static String phoneCheckCodeKey(String phone) {
        return String.format("%s:%s", PHONE_CHECK_CODE_PREFIX, phone);
    }

    public static String emailCheckCodeKey(String email) {
        return String.format("%s:%s", EMAIL_CHECK_CODE_PREFIX, email);
    }
}
